package user

import (
	"context"
	"octopus/user/model/domain/base"
)

type User struct {
	base.AggregateRoot
	ctx       context.Context
	username  string
	password  *Password
	email     *Email
	mobile    *Mobile
	telephone string
	descInfo  string
}

func NewUser(ctx context.Context, id int64, username, password, email, mobile, telephone, descInfo string) *User {
	return &User{
		ctx:           ctx,
		AggregateRoot: base.NewAggregateRoot(id),
		username:      username,
		password:      NewPassword(password),
		email:         NewEmail(email),
		mobile:        NewMobile(mobile),
		telephone:     telephone,
		descInfo:      descInfo,
	}
}

func (u *User) GetUsername() string {
	return u.username
}

func (u *User) GetPassword() *Password {
	return u.password
}

func (u *User) GetEmail() *Email {
	return u.email
}

func (u *User) GetMobile() *Mobile {
	return u.mobile
}

func (u *User) GetTelephone() string {
	return u.telephone
}

func (u *User) GetDescInfo() string {
	return u.descInfo
}

func (u *User) Valid() bool {
	if u.email.IsValid() && u.mobile.IsValidated() {
		return true
	}
	return false
}
